<?php

class PostModel extends Model{
	public function send_post($cate_id, $title, $content) {
		$db = DB::get_instance();
		$stmt = $db->prepare("INSERT INTO entries (category_id, title, body)
		 					  VALUES (?, ?, ?)");
		if (!$stmt->execute(array($cate_id, $title, $content))) {
			return false;
		} else {
			return true;
		}
	}
	public function get_categories() {
		$db = DB::get_instance();
		$r = $db->query("SELECT category_id, name FROM categories");
		$ids = array();
		$names = array();
		foreach ($r as $one) {
			$ids[] = $one["category_id"];
			$names[] = $one["name"];
		}
		return array($ids, $names);
	}
}